<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 15-5-29
 * Time: 下午11:15
 */

class refund extends adminBase{
    function __construct(){
        parent::__construct();
        $this->cms->setPageTitle("退货管理");
        $this->cms->setControlFile("admin/tpl/refund/refund_control.json");
        $admin_info=$this->user->getLoginInfo();
        $user=UserMode::init();
        $levels=$user->getLevels($admin_info['id']);
        if(!$user->checkLevels(12,$levels)){
            $r['message']="您不具有此权限！";
            View::displayAsHtml($r,"plugin/state/tips.php");
            exit();
        }
    }

    function indexTask($page){
        $page=$page>=1? $page: 1;
        $countOfPage=20;
        $offset=($page-1)*$countOfPage;
        $refund=OrderMode::init();
        $user=UserModule::init('user');
        list($r['refund'],$refund_total)=$refund->getRefundList(null,null,$countOfPage,$offset);
        $r['refund']=is_array($r['refund'])?$r['refund']:array();
        foreach($r['refund'] as &$v){
            $user_info=$user->getDetail($v['user_id']);
            $v['user_id']=$user_info['username'];
        }
        $r['currentState']=array(
            'create'=>"申请退款",'apply'=>"已同意退款",'shipped'=>"买家已发货",'confirm'=>"已确认退款"
        );
        $url=WebRouter::init()->getQuestion("page=");
        $r['pages']=new Page($page,$refund_total,$countOfPage);
        $r['pages']->setPageCallback(create_function('$page','return "'.$url.'".$page;'));
        $this->cms->tableScene($r,"admin/tpl/refund/refund.php");
    }
} 